package tree;

/**
 * @Author wangj
 * @Date 2022/4/27 23:02
 */
public class BinaryTreeDemo {

    public static void main(String[] args) {
        HeroNodeTree node1 = new HeroNodeTree(1, "a");
        HeroNodeTree node2 = new HeroNodeTree(2, "b");
        HeroNodeTree node3 = new HeroNodeTree(3, "c");
        HeroNodeTree node4 = new HeroNodeTree(4, "d");
        HeroNodeTree node5 = new HeroNodeTree(5, "e");
        HeroNodeTree node6 = new HeroNodeTree(6, "f");
        HeroNodeTree node7 = new HeroNodeTree(7, "g");

        node1.setLeft(node2);
        node1.setRight(node3);
        node3.setRight(node4);
        node3.setLeft(node5);
        node2.setLeft(node6);
        node2.setRight(node7);
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.setRoot(node1);

        // 1 2 3 4
//        binaryTree.perOrder();
//
//        // 2 1 3 4
//        binaryTree.infixOrder();
//
//        //2 4 3 1
//        binaryTree.postOrder();

        //查找节点
//        System.out.println(binaryTree.postSearchNode(5));

//        System.out.println("删除节点前：");
//        //1267354
//        binaryTree.perOrder();
//        System.out.println("删除节点后3：");
//        binaryTree.delNode(3);
//        // 126754
//        binaryTree.perOrder();

        System.out.println("删除节点前：");
        //1267354
        binaryTree.perOrder();
        System.out.println("删除节点后2：");
        binaryTree.delNode(2);
        // 167354
        binaryTree.perOrder();
    }

}

